<html xmlns="http://www.w3.org/1999/xhtml" class="off">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<style type="text/css">
body,td {font-size:12px;line-height: 22px;}
input.button, input.btn {
    padding: 0.25em;
    width: auto;
    margin:0px auto;
}
.button {
    background: none repeat scroll 0 0 #DDDDDD;
    border-color: -moz-use-text-color #666666 #666666 -moz-use-text-color;
    border-style: none solid solid none;
    border-width: 0 1px 1px 0;
    height: 24px;
    margin-right: 5px;
    padding: 3px 6px;
}
div ul li{list-style:none;margin:0;padding:0}
.table_form tbody td{ border: 1px solid #EEEEEE;}
.division {
    background: none repeat scroll 0 0 #FFFFFF;
    border-color: #CCCCCC #BEC6CE #BEC6CE #CCCCCC;
    border-style: solid;
    border-width: 1px 2px 2px 1px;
    line-height: 150%;
    white-space: normal;
}
.division table {
    margin: 0;
    padding: 0;
}
.division th, .division td {
    border-color: #FFFFFF #DBE2E7 #DDDDDD #FFFFFF;
    border-left: 1px solid #FFFFFF;
    border-right: 1px solid #DBE2E7;
    border-style: solid;
    border-width: 1px;
    padding: 5px;
    vertical-align: top;
}
.division th {
    background: none repeat scroll 0 0 #E2E8EB;
    border-right: 1px solid #CCCCCC;
    font-size: 14px;
    text-align: right;
    white-space: nowrap;
    width: 140px;
}
.gridlist th{
	text-align:center;
	font-weight: bold;
	font-size: 12px;
}
.order_th{font-size: 14px; color: rgb(0, 0, 0); font-weight: bold; margin: 10px;overflow:hidden;}
</style>
<script language="javascript" type="text/javascript" src="/statics/js/jquery-1.4.2.min.js"></script>
</head>
<body onLoad="$('#product_barcode').focus();">

<div style="text-align:center;margin:20px 0px;">
扫描光标区：<input type="text" name="product_barcode" id="product_barcode" /> 
</div>
<form action="__SELF__" method="post" id="myform" name="myform" onSubmit="javascript: return checkshipping()">
<input type="hidden" name="order_sn" id="order_sn"  /> 
<input type="hidden" name="addaction" value="1" />
<div class="division">
<table width="100%" cellspacing="0" cellpadding="2" border="0" class="gridlist">
	<thead> 
			<tr>
			 <th style="width:100px;">商品图片</th>
			 <th style="width:150px;">货号</th>
			 <th style="width:300px;">商品名称</th> 
			 <th style="width:100px;">价格</th> 
			 <th style="width:100px;">购买数量</th> 
			 <th style="width:100px;">已发数量</th> 
			 <th style="width:100px;">发货数量</th> 
			</tr> 
		</thead> 
		<tbody id="productList">
<!--			<tr><td align="center" height="50" colspan="7"><font color="red">订单无商品</font></td></tr>
  	<tr>
			<td align="center"><img src="/data/2013/02/10/thumb_51168d41885fe.jpg" /></td>
			<td align="center">1</td>
			<td>asdfasdf<br/>
				尺码:S , 颜色:军绿色
			</td>
			<td align="center">100.00</td>
			<td align="center">1</td>
			<td align="center">0</td>
			<td align="center">
				<input type="hidden" value="1" name="send[1][id]" /> 
				<input type="text" size="4" value="0" onblur="javascript:checknumber(this.value,1)" name="send[1][number]" autocomplete="off"></td> 
		</tr> -->
	</tbody>

</table>
</div>
<table width="100%" cellspacing="0" cellpadding="2" border="0" class="gridlist">
	 <tbody>
	 <tr>
	 		<th>操作备注：</th>
			<td>
				<textarea rows="3" cols="100" name="action_notice"></textarea>
			</td>
		</tr>
	 	</tbody>
	</table> 
<div style="text-align:center;margin:20px 0px;">
快递单号：<input type="text" name="shipping_no" id="shipping_no" />
</div>
<div style="text-align:center;margin:20px 0px;">
<input class="button" type="submit" name="dosubmit" value="确定">
</div>
</form>
</body>

<script type="text/javascript">
$(function(){
	$('#product_barcode').keyup(function(e){
		var barcode = $('#product_barcode').val();
		   var curKey = e.which;
		   if(curKey == 13)
		   {
			   getProductList();
		   }
		 return false;
	});
	$('#searchOrder').click(function(){
		var ordersn = $('#order_sn').val();
		if(ordersn == ''){
			alert('请输入订单号');
			return false;
		}
		$.post("<?php echo U('order/get_screen_barcode_product_ajax')?>",{order_sn:ordersn},function(data){
		result = eval('(' + data + ')');
			if(result.error==1){
				alert(result.message);
			}else{
				$('#productList').html(result.content);
			}
		});
	});
	
});

function getProductList()
{
	var ordersn = $('#order_sn').val();
	var barcode = $('#product_barcode').val();
	if(ordersn == '' || ordersn != barcode){
		$('#order_sn').val(barcode);
		ordersn = barcode;
	}else if(ordersn == barcode){
		$('#product_barcode').val('');
		alert('请不要多次扫描一个订单号');
		return false;
	}
	

	$.getJSON("<?php echo U('order/getsceenproduct_ajax')?>",{order_sn:ordersn,barcode:barcode},getproductresponse);
}

function getproductresponse(result){
	if(result.error==1){
		$('#order_sn').val('');
		$('#product_barcode').val('');
		alert(result.message);
	}else if(result.error==2){
		$('#product_barcode').val('');
		alert(result.message);
	}else{
		$('#product_barcode').val('');
		$('#productList').html(result.content);
		if(result.add){
			checknumber(result.add.num, result.add.total);
			if(result.add.num <= result.add.total){
				$('#number-'+result.add.id).val(result.add.num);
			}
		}
		//物流号
		if(result.shipping_no){
			$('#shipping_no').val(result.shipping_no);
			$('#myform').submit();
		}
	}
}
function checknumber(i,num){
	if(isNaN(i)){
		alert('发货数量只能为数字');
		return false;
	}else if(i>num){
		alert('发货数量超过应该发的数量:'+num);
		return false;
	}
}
function checkshipping(){
	if($('#order_sn').val() == ''){
		alert('请输入订单号');
		return false;
	}
	if($('#shipping_no').val() == ''){
		alert('请输入物流单号');
		return false;
	}
}
</script>
</html>